<?php

// list of files NOT to put up as links
$ignore = array(".", "..", "index.php", "style.css", "error_log");


// scan files
$files = scandir("./");
$filelist = array();
$count = 0;


// go through files and remove redundant ones.
for($i=0; $i<=(count($files)-1); $i++){
	$current = $files[$i];
	if (!in_array($current, $ignore)){
		$filelist[$count] = $current;
		$count ++;
	}
}
?>
<html>
	<head>
		<title>Downloads</title>
		<link rel="stylesheet" href="style.css" title="style" type="text/css" media="screen" charset="utf-8">
		<link href='http://fonts.googleapis.com/css?family=Orienta' rel='stylesheet' type='text/css'>
	</head>
	<body>
		<div id="wrapper">
			<div id="list">
			<h2>FILE LIST</h2>

			<?php
			for($t=0; $t <= (count($filelist)-1); $t++){
				$url = $filelist[$t];

				$url = explode(".", $url);
				if(isset($url[1])){
					$url[1] = $url[0] . "." . $url[1];
				} else {
					$url[1] = $url[0];
				}
				echo '<a href="'.$url[1].'"><div class="button" align="center">'.$url[0].'</div></a>';
			}
			?>
			</div>
		</div>
	</body>
</html>
